package com.bms.api.bussiness.company.web;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.bms.api.base.annotation.LoginMemId;
import com.bms.common.base.common.bean.Result;
import com.bms.common.base.web.BaseController;
import com.bms.common.bussiness.company.entity.Company;
import com.bms.common.bussiness.company.service.ICompanyService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.annotations.ApiIgnore;

/**
 * <p>
 * 部门管理  前端控制器
 * </p>
 *
 * @author xj
 * @since 2018-08-09
 */
@RestController
@RequestMapping("company")
@Api(value="Company-Api",tags="公司管理")
public class CompanyController extends BaseController {

	@Autowired
	private ICompanyService companyService;
	
	@Validated
	@ApiOperation("申请公司")
	@PostMapping("apply.auth")
	public Result save(@ApiIgnore @LoginMemId String openId, @RequestBody Company company){
		Date now = new Date();
		company.setOpenId(openId);
		company.setCreateTime(now);
		company.setUpdateTime(now);
		company.setStatus(1);
		companyService.saveApply(company);
		return success();
	}
	
}
